﻿@using Matrix.Common.Utility.MvcHelper
@model Matrix.MaKaYunShang.Model.Dto.RolePermissionDto

@{
    ViewBag.Title = "编辑权限";
    ViewBag.PathToBtn = "/RolePermission/List";
    ViewBag.TextBtn = "返回至列表";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<!-- /.row -->
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                权限信息
            </div>
            <div class="panel-body">
                <div class="row">
                    @using (Html.BeginForm("Update", "RolePermission", FormMethod.Post, new {id = "frmUpdate", enctype = "multipart/form-data"}))
                    {
                        @Html.AntiForgeryToken()
                        @Html.ValidationSummary(true)
                        
                        @Html.HiddenFor(model => model.ShopId)
                        @Html.HiddenFor(model => model.RoleId)
                        <div class="col-lg-12">
                            <fieldset>
                                <div class="form-group col-md-6">
                                    <label>当前编辑角色</label>
                                    <div class="input-group">
                                        @Html.DisplayFor(model => model.RoleName, new { @class = "form-control" })
                                    </div>
                                </div>
                                <div class="form-group col-md-6">
                                    <label>授予权限</label>
                                    <div class="input-group">
                                        <p><label> <input type="checkbox" checked="checked" disabled="disabled" style="border:none;">  订单查看</label></p>
                                        @Html.CheckBoxList("Modules", false)
                                    </div>
                                </div>
                                
                                <div class="col-md-12">
                                    <button id="btnSave" type="submit" class="btn btn-primary">确认并保存</button>
                                </div>
                            </fieldset>
                        </div>
                    }
                </div>
                <!-- /.row (nested) -->
            </div>
            <!-- /.panel-body -->
        </div>
        <!-- /.panel -->
    </div>
    <!-- /.col-lg-12 -->
</div>
<!-- /.row -->

@section javascript{
    <script type="text/javascript">
        $(function () {
            $("input[name='Modules']").each(function () {
                var lsData = eval(@Html.Raw(Model.ListModules));
                for (var j = 0; j < lsData.length; j++) {
                    if ($(this).val() == lsData[j].ModuleId) {
                        $(this).attr("checked", "checked");
                        break;
                    }
                }
            });
        })
    </script>
}